package com.iyundao.io.controller;

import com.alibaba.fastjson.JSONObject;
import com.iyundao.io.Service.SysUserService;
import com.iyundao.io.model.SysUser;
import com.iyundao.io.tools.ResponseData;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/administrator")
public class AdministratorController {

    @Autowired
    private SysUserService sysUserService;

    @ApiOperation(value="添加管理员", notes="添加管理员")
    @RequestMapping(value = "/newadministrator", produces = {"application/json;charset=UTF-8"})
    @CrossOrigin
    public ResponseData newAdministrator(@RequestBody String params){
        JSONObject object = JSONObject.parseObject(params);
        SysUser sysUser = (SysUser) object.get("sysUser");
        String id = (String) object.get("id");
        return sysUserService.addAdministrator(sysUser,id);
    }

}
